<template>
  <div id="app">
    <router-view/>
  </div>
</template>
<script>
import { setConfigList } from "@/utils/storage.js";
export default {
  data() {
    return {
      time: 0,
    }
  },
  methods: {
    exitApp() {
      plus.key.addEventListener("backbutton", () => {
        if (this.time === 0 || new Date().getTime() - this.time > 2 * 1000) { // 第一次点击 或是 下一次比上一次点击间隔2s
          this.$toast({
            message: "再按一次返回键退出",
            duration: 2000,
            position: "bottom"
          });
          this.time = new Date().getTime();
        } else {
          plus.webview.currentWebview().close();
        }
      });
    }
  },
  mounted() {
    document.addEventListener('plusready',() => {  
      setConfigList();
      this.exitApp();
    },false);
  }
};
</script>
